﻿namespace Smart.Utils.UI.BarcodeLib
{
    using System;

    internal class Standard2of5 : BarcodeCommon, IBarcode
    {
        private string[] S25_Code = new string[] { "11101010101110", "10111010101110", "11101110101010", "10101110101110", "11101011101010", "10111011101010", "10101011101110", "10101110111010", "11101010111010", "10111010111010" };

        public Standard2of5(string input)
        {
            base.Raw_Data = input;
        }

        private string Encode_Standard2of5()
        {
            if (!BarcodeEdit.CheckNumericOnly(base.Raw_Data))
            {
                throw new Exception("ES25-1: Numeric Data Only");
            }
            string str = "11011010";
            foreach (char ch in base.Raw_Data)
            {
                str = str + this.S25_Code[int.Parse(ch.ToString())];
            }
            return (str + "1101011");
        }

        public string Encoded_Value
        {
            get
            {
                return this.Encode_Standard2of5();
            }
        }
    }
}

